const fs = require('fs');
const path = require('path');
const mineType = require('mime-types');
module.exports = function (url, callback) {
    try {
        let filePath = path.resolve(url);
        let data = fs.readFileSync(filePath);
        data = new Buffer(data).toString('base64');
        let base64 = 'data:' + mineType.lookup(filePath) + ';base64,' + data;
        callback(false, base64);
    } catch (error) {
        callback(error, null);
    };
};
